/* GUI CONVERTED from rprsmt.p (converter v1.75) Sat Aug 12 23:11:47 2000 */
/* rprsmt.p - RESOURCES MAINTENANCE                                       */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                    */
/* All rights reserved worldwide.  This is an unpublished work.           */
/*F0PN*/ /*V8:ConvertMode=Maintenance                                     */
/*K1Q4*/ /*V8:RunMode=Character,Windows                                   */
/* REVISION: 1.0     LAST MODIFIED: 05/05/85    BY: pml                   */
/* REVISION: 1.0     LAST MODIFIED: 01/24/86    BY: emb                   */
/* REVISION: 2.0     LAST MODIFIED: 03/12/87    BY: emb *A41*             */
/* REVISION: 2.0     LAST MODIFIED: 07/09/87    BY: emb *A76*             */
/* REVISION: 7.3     LAST MODIFIED: 10/26/92    BY: ram *G235*            */
/* REVISION: 7.2     LAST MODIFIED: 05/03/94    BY: pma *FN89*            */
/* Oracle changes (share-locks)    09/13/94           BY: rwl *GM47*      */
/* REVISION: 7.5     LAST MODIFIED: 10/24/94    BY: mwd *J034*            */
/* REVISION: 7.3     LAST MODIFIED: 03/05/97   BY: *G2LB* Jack Rief       */
/* REVISION: 7.4     LAST MODIFIED: 01/02/98   BY: *H1HW* Jean Miller     */
/* REVISION: 8.6     LAST MODIFIED: 05/20/98   BY: *K1Q4* Alfred Tan      */
/* REVISION: 9.1      LAST MODIFIED: 03/24/00 BY: *N08T* Annasaheb Rahane */
/* REVISION: 9.1      LAST MODIFIED: 08/12/00 BY: *N0KP* myb              */
/**************************************************************************/

         /* DISPLAY TITLE */
         {mfdtitle.i "b+ "}

         define variable del-yn like mfc_logical initial no.
/*H1HW*/ define variable rs-rsc  like rs_mstr.rs_rsc.
/*H1HW*/ define variable rs-um   like rs_mstr.rs_um.

         /* DISPLAY SELECTION FORM */
         
/*GUI preprocessor Frame A define */
&SCOPED-DEFINE PP_FRAME_NAME A

FORM /*GUI*/ 
/*H1HW*    rs_rsc         colon 25  rs_site colon 50 */
/*H1HW*/   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
rs-rsc         colon 25  rs_site colon 50
           rs_desc        colon 25
/*H1HW*    rs_um          colon 25  */
/*H1HW*/   rs-um         colon 25
          SKIP(.4)  /*GUI*/
with frame a side-labels width 80 attr-space NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-a-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
 RECT-FRAME-LABEL:HIDDEN in frame a = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame a =
  FRAME a:HEIGHT-PIXELS - RECT-FRAME:Y in frame a - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME a = FRAME a:WIDTH-CHARS - .5.  /*GUI*/

/*GUI preprocessor Frame A undefine */
&UNDEFINE PP_FRAME_NAME



         /* SET EXTERNAL LABELS */
         setFrameLabels(frame a:handle).

         display global_site @ rs_site with frame a.

         /* DISPLAY */
         view frame a.

         mainloop:
         repeat with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.


/*G2LB*/    clear frame b all.
/*H1HW*     prompt-for rs_rsc rs_site editing: */
/*H1HW*/    prompt-for rs-rsc rs_site editing:

               /* FIND NEXT/PREVIOUS RECORD */
/*H1HW*        {mfnp.i rs_mstr rs_rsc rs_rsc rs_rsc rs_rsc rs_rsc} */
/*H1HW*/       {mfnp.i rs_mstr rs-rsc rs_rsc rs-rsc rs_rsc rs_rsc}

               if recno <> ? then
               display
/*H1HW*           rs_rsc */
/*H1HW*/          rs_rsc @ rs-rsc
                  rs_site
                  rs_desc
/*H1HW*           rs_um. */
/*H1HW*/          rs_um @ rs-um.
            end.

/*H1HW*/    /* VALIDATE rs-rsc is NOT BLANK */
/*H1HW*/    if input rs-rsc = "" then do:
/*H1HW*/       {mfmsg.i 40 3} /* BLANK NOT ALLOWED */
/*H1HW*/       next-prompt rs-rsc with frame a.
/*H1HW*/       undo, retry.
/*H1HW*/    end.

/*J034*/    {gprun.i ""gpsiver.p""
             "(input (input rs_site), input ?, output return_int)"}
/*GUI*/ if global-beam-me-up then undo, leave.

/*J034*/    if return_int = 0 then do:
/*J034*/       {mfmsg.i 725 3} /*USER DOES NOT HAVE ACCESS TO THIS SITE */
/*J034*/       next-prompt rs_site with frame a.
/*J034*/       undo, retry.
/*J034*/    end.

            /* ADD/MOD/DELETE */
            del-yn = no.
/*H1HW*     find rs_mstr using rs_rsc and rs_site no-error. */
/*H1HW*/    find rs_mstr where rs_rsc = input rs-rsc
/*H1HW*/                   and rs_site = input rs_site
/*H1HW*/    exclusive-lock no-error.

            if not available rs_mstr then do:
               {mfmsg.i 1 1} /* ADDING NEW RECORD */
               create rs_mstr.
/*H1HW*        assign rs_rsc rs_site. */
/*H1HW*/       assign
/*H1HW*/          rs_rsc = input rs-rsc
/*H1HW*/          rs_site.
            end.

            recno = recid(rs_mstr).
            display
/*H1HW*        rs_rsc */
/*H1HW*/       rs_rsc @ rs-rsc
               rs_desc
/*H1HW*        rs_um. */
/*H1HW*/       rs_um @ rs-um.

            ststatus = stline[2].
            status input ststatus.

            do on error undo, retry with frame a:
/*GUI*/ if global-beam-me-up then undo, leave.

/*H1HW*        set */
/*H1HW*/       prompt-for
                  rs_desc
/*H1HW*           rs_um  */
/*H1HW*/          rs-um
               go-on ("F5" "CTRL-D").

               /* DELETE */
               if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
               then do:
/*G235*/          if can-find(first pq_mstr where pq_rsc = rs_rsc
/*G235*/          and pq_site = rs_site) then do:
/*G235*/             {mfmsg.i 412 4}
/*G235*/             /* DELETE NOT ALLOWED, RESOURCE USED IN PL RESOURCE BILL */
/*G235*/             undo, retry.
/*G235*/          end.
/*G235*/          if can-find(first rq_mstr where rq_rsc = rs_rsc
/*G235*/          and rq_site = rs_site) then do:
/*G235*/             {mfmsg.i 413 4}
/*G235*/             /* DELETE NOT ALLOWED, RESOURCE USED IN ITEM RESOURC BILL */
/*G235*/             undo, retry.
/*G235*/          end.

                  del-yn = yes.
                  {mfmsg01.i 11 1 del-yn} /* PLEASE CONFIRM DELETE */
                  if del-yn = no then undo, retry.
/*GM47*/          for each rsd_det exclusive-lock where rsd_rsc = rs_rsc
                  and rsd_site = rs_site:
                     delete rsd_det.
                  end.
                  delete rs_mstr.
                  clear frame a.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame a = F-a-title.
                  del-yn = no.
                  next mainloop.
               end. /* if F5 or CTRL-D */

/*H1HW*/       /* VALIDATE rs-um is NOT BLANK */
/*H1HW*/       if input rs-um = "" then do:
/*H1HW*/          {mfmsg.i 40 3} /* BLANK NOT ALLOWED */
/*H1HW*/          next-prompt rs-um.
/*H1HW*/          undo, retry.
/*H1HW*/       end.

/*H1HW*/       assign
/*H1HW*/          rs_desc
/*H1HW*/          rs_um = input rs-um.

               /* DETAIL */
               repeat with frame b:
/*GUI*/ if global-beam-me-up then undo, leave.


                  FORM /*GUI*/ 
                     rsd_ref
                     rsd_start
                     rsd_end
                     rsd_cap
                  with frame b width 80 attr-space down THREE-D /*GUI*/.


                  /* SET EXTERNAL LABELS */
                  setFrameLabels(frame b:handle).

                  prompt-for rsd_ref editing:

                     /* FIND NEXT/PREVIOUS RECORD */
                     {mfnp05.i rsd_det rsd_rsc
                      "rsd_site = rs_site and rsd_rsc = rs_rsc"
                      rsd_ref "input rsd_ref"}

                     if recno <> ? then
                     display
                        rsd_ref
                        rsd_start
                        rsd_end
                        rsd_cap.
                  end.

                  /* ADD/MOD/DELETE */
                  del-yn = no.
                  find rsd_det where rsd_rsc = rs_rsc
                                 and rsd_site = rs_site
                                 and rsd_ref = input rsd_ref
                  exclusive-lock no-error.
                  if not available rsd_det then do:
                     {mfmsg.i 1 1} /* ADDING NEW RECORD */
                     create rsd_det.
                     assign
                        rsd_rsc = rs_rsc
                        rsd_site = rs_site
                        rsd_ref.
                  end.

                  recno = recid(rsd_det).
/*FN89*           display rsd_ref rsd_start rsd_end rsd_cap.   */

                  ststatus = stline[2].
                  status input ststatus.

                  do on error undo, retry:
/*GUI*/ if global-beam-me-up then undo, leave.

/*FN89*/             display rsd_ref rsd_start rsd_end rsd_cap.
/*G2LB*              set rsd_start rsd_end rsd_cap go-on("F5" "CTRL-D"). */
/*G2LB*/             update rsd_start rsd_end rsd_cap go-on("F5" "CTRL-D").

/*FN89*/             if input rsd_start > input rsd_end then do:
/*FN89*/                {mfmsg.i 4 3} /* START DATE MUST BE PRIOR TO END DATE */
/*FN89*/                undo, retry.
/*FN89*/             end.

                     /* DELETE */
                     if lastkey = keycode("F5") or lastkey = keycode("CTRL-D")
                     then do:
                        del-yn = yes.
                        {mfmsg01.i 11 1 del-yn} /* PLEASE CONFIRM DELETE */
                        if del-yn = no then undo, retry.
                        delete rsd_det.
                        del-yn = no.
                     end.
                  end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* do on error undo, retry */

               end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* repeat */

            end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* do on error, undo */

         end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* mainloop, repeat with frame a */

         status input.
